package com.sks.web.action.privilege;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.DelegatingRequestProcessor;

import com.sks.utils.WebUtil;

public class PrivilegeRequestProcessor extends DelegatingRequestProcessor {
	
	

	@Override
	protected ActionForward processActionPerform(HttpServletRequest request,
			HttpServletResponse response, Action action, ActionForm form,
			ActionMapping mapping) throws IOException, ServletException {
		
		
		String uri = WebUtil.getRequestURI(request);
		
		// 只对办公平台中的action进行校验
		if (uri.startsWith("/control/") || uri.startsWith("/cms/") || uri.startsWith("/sks/cms/")) {
			if (!WebUtil.validate(request, action, mapping)) {// 没有权限的时候执行下面这段代码
				request.setAttribute("message", "您没有执行该操作的权限，请联系系统管理员！");
				return mapping.findForward("message");
			}
		}
		return super.processActionPerform(request, response, action, form, mapping);
	}
	

}
